package com.fs.book.web;


import com.fs.book.entity.Student;
import com.fs.book.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
@RequestMapping("test")
public class TestController {
    @Autowired
    private Environment environment; //只能获取单个值

    @Autowired
    private User user;

    @Autowired
    private Student stu;

    @Value("${suke.str}")
    private String randmonStr;

    @RequestMapping("test1")
    public String test1(){
        String str = environment.getProperty("str");
        String name = environment.getProperty("user1.loginname");
        String num1 = environment.getProperty("arr1[0]");
        System.out.println(user);
        System.out.println(stu);
        System.out.println(Arrays.asList(stu.getLove()));
        return str+"-->"+name+"-->"+num1+"-->"+randmonStr;
    }
}
